package com.zhuoyue.system.service.impl;

import com.zhuoyue.common.core.domain.entity.SysDictData;
import com.zhuoyue.common.core.domain.entity.SysThirdData;
import com.zhuoyue.common.utils.DateUtils;
import com.zhuoyue.system.mapper.SysDictDataMapper;
import com.zhuoyue.system.mapper.SysThirdDataMapper;
import com.zhuoyue.system.service.ISysThirdDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author zhanghui
 */
@Service
public class SysThirdDataServiceImpl implements ISysThirdDataService {
    @Autowired
    private SysThirdDataMapper sysThirdDataMapper;

    @Autowired
    private SysDictDataMapper sysDictDataMapper;

    @Override
    public SysThirdData selectSysThirdDataById(String id) {
        return sysThirdDataMapper.selectSysThirdDataById(id);
    }

    @Override
    public List<SysThirdData> selectSysThirdDataList(SysThirdData sysThirdData) {
        return sysThirdDataMapper.selectSysThirdDataList(sysThirdData);
    }


    @Override
    public int insertSysThirdData(SysThirdData sysThirdData) {
        return sysThirdDataMapper.insertSysThirdData(sysThirdData);
    }


    @Override
    public int updateSysThirdData(SysThirdData sysThirdData) {
        sysThirdData.setUpdateTime(DateUtils.getNowDate());
        return sysThirdDataMapper.updateSysThirdData(sysThirdData);
    }


    @Override
    public int deleteSysThirdDataByIds(String[] ids) {
        return sysThirdDataMapper.deleteSysThirdDataByIds(ids);
    }


    @Override
    public int deleteSysThirdDataById(String id) {
        return sysThirdDataMapper.deleteSysThirdDataById(id);
    }

    @Override
    public SysThirdData selectJPushData(Long deptId) {
        // 先查询字典数组中第三方平台dictCode
        SysDictData dictData = sysDictDataMapper.getJpushDictData();

        // 根据极光推送的dictCode和组织ID查询第三方平台数据
        SysThirdData jPush = sysThirdDataMapper.getJPushDataByDeptId(dictData.getDictCode(), deptId);
        return jPush;
    }

    @Override
    public List<SysThirdData> selectJPushDataList() {
        // 先查询字典数组中第三方平台dictCode
        SysDictData dictData = sysDictDataMapper.getJpushDictData();

        // 根据极光推送的dictCode和组织ID查询第三方平台数据
        List<SysThirdData> jPush = sysThirdDataMapper.getJPushDataList(dictData.getDictCode());
        return jPush;
    }

    @Override
    public SysThirdData selectYunPianData(Long deptId) {
        return null;
    }
}
